from flask import Flask, render_template
import datetime
import pandas as pd

server = Flask(__name__)


@server.route('/', methods=['post', 'get'])
def show():
    now = str(datetime.datetime.now())  # 把当前时间转换成字符串
    # return "当前的时间是：%s" % now
    data = pd.read_csv("data.csv")
    # print(data)
    data = data.rename(columns={"3": "name", "2": "value", "1": "age"})
    # print(data)
    # 整理格式为 [{value:121212,name:剧情, 年龄:26},{...}...]
    data = data.to_dict(orient="records")
    print(data)

    return render_template("show3.html",data=data,time=now)


server.run(debug=True, port=8888)
